<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page import="com.magical.entity.Files" %>
<%@ page import="java.util.List" %>
<%@ page import="com.magical.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: Pei
  Date: 2018/5/30
  Time: 8:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/lightbox.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/layer.js"></script>
    <script src="/js/ckplayer/ckplayer.js"></script>
    <script src="http://static.bcedocument.com/reader/v2/doc_reader_v2.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script src="/js/main.js"></script>
</head>
<body>
<div>

    <div class="panel panel-default" style="margin-left: 10px; margin-top: 10px">
        <!-- Default panel contents -->
        <div class="panel-heading" id="pathnav">


            <%
                Files file = (Files) request.getAttribute("file");
                String ids = (String) request.getAttribute("ids");

                if (file != null) {
                    String path = file.getFullPath();
                    String[] p = path.split("\\\\");
                    String[] id = ids.split("-");
                    int index = 0;
                    for (int i = 0; i < p.length; i++) {
                        if (p[i].equals("upload")) {
                            index = i;
                            break;
                        }
                    }
                    for (int i = index + 2; i < p.length; i++) {
            %>

            <a href="/files/search2?folderId=<%=id[i-index-1]%>&path=<%=ids%>"> /  <%=p[i]%>
            </a>
            <%
                    }
                }
            %>
            <span id="navPath">

			</span>
        </div>

        <table class="table table-hover" id="mytable">
            <thead>
            <tr>
                <th colspan="4" width="800px" align="left">文件名</th>
                <th width="20%">大小</th>
                <th >修改时间</th>
            </tr>
            </thead>
            <%!
                boolean isShield(String[] shields, String id) {
                    if (shields != null && shields.length > 0) {
                        for (String s : shields) {
                            if (s.equals(id))
                                return true;
                        }
                    } else {
                        return false;
                    }
                    return false;
                }
            %>
            <% List<Files> subfiles = (List<Files>) request.getAttribute("subfiles");
                String idss = (String) request.getAttribute("idss");
                String[] shields = null;
                if (idss != null) shields = idss.split(",");
            %>
            <tbody id="list">
            <%
                if (subfiles != null && subfiles.size() != 0) {
                    for (Files files : subfiles) {
            %>
            <tr>

                <td colspan="4" width="40%">
                    <%
                        if (files.getFiletypeId() == 5) {
                            if (!isShield(shields, files.getFileId())) {
                    %>

                    <a href="/files/search2?folderId=<%=files.getFileId()%>&path=<%=ids%>&ids=<%=idss%>">
                            <%
                        }else{
                %>
                        <a>
                            <%
                                    }
                                }
                            %>
                            <%=files.getFileName()%>
                            <%if (files.getFiletypeId() == 5) {%>
                        </a>
                            <%}%>
                </td>
                <td align="center"><%=files.getFileSize()%>
                </td>
                <td align="center"><%=files.getStringTime()%>
                </td>
            </tr>
            <%
                    }
                }
            %>
            </tbody>

        </table>
    </div>
</div>


<script src="/js/jquery-1-4-2.min.js"></script>
<script src="/js/public-method.js"></script>
<script>

    function setvalue() {
        var x = window.parent.document.getElementById("toId");
        x.value = getQueryString("folderId");

    }

    $(document).ready(function read(e) {
        var ids = getQueryString("ids");
        if (getQueryString("folderId") == null || getQueryString("folderId") == "") {
            window.location.href = "/files/search2?folderId=<%=((User)session.getAttribute("loginUser")).getId()%>&idss=" + ids;
        }
        setvalue();
    });


</script>


</body>
</html>
